package com.cy.pj.sys.controller;

import com.cy.pj.common.vo.JsonResult;
import com.cy.pj.sys.pojo.Role;
import com.cy.pj.sys.service.AdminRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AdminRoleController {
    @Autowired
    private AdminRoleService adminRoleService;

    @RequestMapping("/selectAssignedRole")
    public JsonResult selectAssignedRole(Integer adminId){
        List<Role> list = adminRoleService.selectAssignedRole(adminId);
        return new JsonResult(list);
    }

    @RequestMapping("/selectUnAssignedRole")
    public JsonResult selectUnAssignedRole(Integer adminId){
        List<Role> list = adminRoleService.selectUnAssignedRole(adminId);
        return new JsonResult(list);
    }

    @RequestMapping("/insertAssignedRole")
    public JsonResult insertAssignedRole(Integer adminId, Integer[] roleIds){
        adminRoleService.insertAssignedRole(adminId,roleIds);
        return new JsonResult("分配成功");
    }

    @RequestMapping("/deleteAssignRole")
    public JsonResult deleteAssignRole(Integer adminId, Integer[] roleIds){
        adminRoleService.deleteAssignRole(adminId,roleIds);
        return new JsonResult("分配成功");
    }
}
